package libcore.kotpref

import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

class IntPref(private val key: String, private val defaultValue: Int) :
    ReadWriteProperty<KotPrefBase, Int> {
    override fun getValue(thisRef: KotPrefBase, property: KProperty<*>): Int {
        return thisRef.sharedPreferences.getInt(key, defaultValue)
    }

    override fun setValue(thisRef: KotPrefBase, property: KProperty<*>, value: Int) {
        thisRef.sharedPreferences.edit().putInt(key, value).commit()
    }

}